package com.panda.mall.wares.brand.controller;

import com.panda.mall.common.mallWares.entity.MallGoodsBrand;
import com.panda.mall.common.result.Result;
import com.panda.mall.wares.brand.service.MallGoodsBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * author: tcy
 * createDate: 2023/2/22
 * description: 品牌管理控制
 */
@Api(tags = "品牌管理")
@RestController
@RequestMapping("/wares")
public class BrandController {

    @Autowired
    MallGoodsBrandService mallGoodsBrandService;

    @ApiOperation(value = "新增或修改品牌", notes = "新增或修改品牌")
    @PostMapping("/brand/saveOrUpdateBrand")
    public Result<String> saveOrUpdateBrand(@RequestBody MallGoodsBrand mallGoodsBrand){
        return Result.success(mallGoodsBrandService.saveOrUpdateBrand(mallGoodsBrand));
    }

    @ApiOperation(value = "查询全部品牌", notes = "查询全部品牌")
    @GetMapping("/brand/queryBrand")
    public Result<List<MallGoodsBrand>> queryBrand(){
        return Result.success(mallGoodsBrandService.queryBrand());
    }

    @ApiOperation(value = "根据id查询品牌", notes = "根据id查询品牌")
    @GetMapping("/brand/queryBrandById/{id}")
    public Result<List<MallGoodsBrand>> queryBrandById(@PathVariable("id") String id){
        return Result.success(mallGoodsBrandService.queryBrandById(id));
    }

    @ApiOperation(value = "根据id删除品牌", notes = "根据id删除品牌")
    @GetMapping("/brand/deleteBrandById/{id}")
    public Result<Boolean> deleteBrandById(@PathVariable("id") String id){
        return Result.success(mallGoodsBrandService.deleteBrandById(id));
    }

}
